<?php include TMPL_PATH.'public/header.phtml';?>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
    	<div style="float:left;margin-right:50px;">
        <a href='javascript:;' class="on"><em>文章列表</em></a><span>|</span>
        <a href='<?php echo U('article/article_add');?>' ><em>添加文章</em></a>
      </div>
       <?php 
				 $searchtype = isset($search)&& $search['searchtype'] ? $search['searchtype'] : 0;
				 $searchkeyword = isset($search)&& $search['keyword'] ? $search['keyword'] : null;
				 $istop = isset($search['istop']) ? ($search['istop'] ? $search['istop'] : 0) : null;
				 ?>
    	<div style="color:#000;">
    		<form name="searchform" action="__SELF__"  method="post">
    		<input type="hidden" value="1" name="search">
    		文章分类：<select name="catid" id="cid"><option value=''>≡ 全部分类  ≡</option>
				<?php echo $select_categorys;?>
				</select>&nbsp;&nbsp;&nbsp;
				推荐：<select name="recommendid" id="recommendid">
				 	<option value=''>全部</option>
				 	<?php 
				 	$recommendid = isset($search)&& $search['recommendid'] ? $search['recommendid'] : 0;
				 	if (isset($recommendArray) && $recommendArray):
				 		foreach ($recommendArray as $key => $val):
				 	?>
				 	<option value='<?php echo $key?>' <?php if($key==$recommendid)echo 'selected';?>><?php echo $val;?></option>
				 	<?php 
				 		endforeach;
				 	endif;
				 	?>
				 </select>&nbsp;&nbsp;&nbsp;<select name="searchtype">
					<option <?php if($searchtype==0)echo 'selected';?> value="0">标题</option>
					<option value="1" <?php if($searchtype==1)echo 'selected';?>>ID</option>
				</select>
				<input type="text" class="input-text" value="<?php echo $searchkeyword;?>" name="keyword">
				<input type="submit" value="搜索" class="button" name="search">
    		</form>
    	</div>
    </div>
</div>
<div class="bk"></div>
<div class="pad_10">
<div class="table-list">
    <table width="100%" cellspacing="0" >
        <thead>
            <tr>
            <th width="38">排序</th>
            <th width="50">ID</th>
            <th align='left'>文章名称</th>
            <th align='left' width="200">分类名称</th>
            <th align='center' width="80">点击量</th>
<!--            <th align='center' width="80">发布人</th>-->
            <th align='center' width="150">更新时间</th>
            <th align='center' width="30">状态</th>
						<th>管理操作</th>
            </tr>
        </thead>
    <tbody>
    <?php 
   	if(isset($articleList) && $articleList):
   		foreach ($articleList as $v):
   ?>
			<tr>
					<td align='center'><input id="listorder-<?php echo $v['id']?>" name='listorders[<?php echo $v['id']?>]' type='text' size='3' title="当光标离开输入框后修改排序" value='<?php echo $v['listorder']?>' onblur="javascript:setting_listorder(<?php echo $v['id']?>);" class='input-text-c'></td>
					<td align='center'><?php echo $v['id']?></td>
					<td><?php echo $v['name']?></td>
					<td align='left'><?php echo $v['catname'];?></td>
					<td align='center'><?php echo $v['visit'];?></td>
					<!--<td align='center'><?php echo $v['author']?></td>
					--><td align='center'><?php echo date('Y-m-d H：i:s', $v['end_time'] ? $v['end_time'] : $v['start_time']);?></td>
					<td align='center' id="status-<?php echo $v['id']?>">
					<?php if($v['display']):?>
					<a href="javascript:setting_status(<?php echo $v['id']?>,0);"><font color="red">√</font></a>
					<?php else:?>
					<a href="javascript:setting_status(<?php echo $v['id']?>,1);"><font color="blue">×</font></a>
					<?php endif;?>
					</td>
					<td align='center'> 
					<a href="<?php echo U('article/article_edit', 'aid='.$v['id']);?>">修改</a> | 
					<a href="javascript:confirmurl('<?php echo U('article/article_delete', 'aid='.$v['id']);?>','确认要删除 『<?php echo $v['name']?>』 吗？')">删除</a>
					</td>
				</tr>
	<?php 
		endforeach;
		endif;
	?>
   </tbody>
    </table>
<div id="pages"><?php echo $pageShow;?></div>
</div>
</div>
</body>
</html>
<script type="text/javascript">
<!--
function setting_listorder(id){
	var lisobj = $('#listorder-'+id);
	listorder = parseInt(lisobj.val());
	if(isNaN(listorder)){
		alert('排序只能设置为整数.');return;
	}
	$.get('<?php echo U('article/change_article_listorder_ajax');?>',{aid:id,listorder:listorder},function(data){
		if(data==1){lisobj.val(listorder)}
	});
}
function setting_status(id,display){
	$.get('<?php echo U('article/change_status_ajax');?>',{aid:id,display:display},function(){
			if(display==0){
				$('#status-'+id).html('<a href="javascript:setting_status('+id+',1);"><font color="blue">×</font></a>');
			}else{
				$('#status-'+id).html('<a href="javascript:setting_status('+id+',0);"><font color="red">√</font></a>');
			}
		});
}
//-->
</script>